package com.starry.home.viewmodel.login

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.switchMap
import com.starry.home.logic.model.login.LoginBean
import com.starry.home.logic.network.Repository
import com.starry.core.viewmodel.BaseViewModel

/**
 * Package:com.starry.dotpen_patients.viewmodel.login
 * Author:starr
 * Time:2024/1/3 20:32
 * Description:
 */
class LoginViewModel : BaseViewModel() {



    private val _loginBeanLiveData = MutableLiveData<LoginBean>()

    //外部观测这个返回结果
    val loginResponseBean =
        _loginBeanLiveData.switchMap { loginBean -> Repository.login(loginBean) }


    fun login(params: LoginBean) {
        _loginBeanLiveData.value = params
    }
    /**
     * 注册
     */
    fun register(params: LoginBean){
        _registerBeanLiveData.value = params
    }


    private val _registerBeanLiveData = MutableLiveData<LoginBean>()
    val registerBean =
        _registerBeanLiveData.switchMap { registerBean -> Repository.register(registerBean) }
}